#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int a[n];
	int count = 0;
	int i = 0;
	
	while(i < n)
	{
		scanf("%d", &a[i++]);
	}
	
	sort(a, a + n);
	
	for (i = 0; i < n - 1; i++)
	{
		if (a[i+1] - a[i] == 1)
			count++;	
	}
	printf("%d", count);
	return 0;
}
